const db = wx.cloud.database()
Page({
  onLoad() {
    this.getList()
  },
  getList() {
    wx.cloud.callFunction({
        name: 'admin',
        data: {
          action: 'getStudents'
        }
      })
      .then(res => {
        console.log('学生数据', res)
        this.setData({
          list: res.result.data
        })
      })
  },
  // 拒绝
  refuse(e) {
    let id = e.currentTarget.dataset.id
    wx.cloud.callFunction({
        name: 'admin',
        data: {
          action: 'refuse',
          id
        }
      })
      .then(res => {
        console.log('拒绝', res)
        wx.showToast({
          title: '操作成功',
        })
        this.getList()
      })
  },
  // 审核通过
  adopt(e) {
    let id = e.currentTarget.dataset.id
    wx.cloud.callFunction({
        name: 'admin',
        data: {
          action: 'adopt',
          id
        }
      })
      .then(res => {
        console.log('通过', res)
        wx.showToast({
          title: '操作成功',
        })
        this.getList()
      })
  }

})